home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 119
/
(Vol 119) Nov 09 2010.iso
/
TGKI-109
/
Games
/
fratboy_girlfriend_tower_defense.swf
/
scripts
/
frame_954
/
DoAction.as
Wrap
Text File
|
2010-11-09
|
31KB
|
969 lines
function kaplyaMove()
{
this._x += this.prirostX;
this._y += this.prirostY;
this.prirostX /= 2;
this.prirostY /= 2;
this._alpha -= 13;
if(this._alpha <= -100)
{
this.swapDepths(99999);
removeMovieClip(this);
}
}
function razriv(xx, yy, amount)
{
i = 0;
while(i < amount)
{
_root.kaplyaCounter = _root.kaplyaCounter + 1;
_root.attachMovie("kaplya","kaplya" + kaplyaCounter,_root.getNextHighestDepth(),{_x:xx,_y:yy});
eval("kaplya" + kaplyaCounter).prirostX = random(30) - 15;
eval("kaplya" + kaplyaCounter).prirostY = random(30) - 15;
eval("kaplya" + kaplyaCounter).onEnterFrame = kaplyaMove;
eval("kaplya" + kaplyaCounter).counter = 20;
eval("kaplya" + kaplyaCounter)._xscale = eval("kaplya" + i)._yscale = random(70) + 70;
i++;
}
}
function missileMove()
{
this._x -= (this._x - eval("a" + this.trg).mc._x) / this.toTarget;
this._y -= (this._y - eval("a" + this.trg).mc._y + 30) / this.toTarget;
this.toTarget--;
if(eval("a" + this.trg).mc._x == undefined)
{
this.swapDepths(99999);
}
removeMovieClip(this);
if(this.sensor.hitTest(eval("a" + this.trg).mc))
{
if((this.towerType == 1 || this.towerType == 6) && creatureType == 2)
{
eval("a" + this.trg).mc.estimatedDamage -= missileDamage[this.towerType][this.level - 1] / 2;
eval("a" + this.trg).mc.health -= missileDamage[this.towerType][this.level - 1] / 2;
}
else
{
eval("a" + this.trg).mc.estimatedDamage -= missileDamage[this.towerType][this.level - 1];
eval("a" + this.trg).mc.health -= missileDamage[this.towerType][this.level - 1];
}
if(this.towerType == 5)
{
eval("a" + this.trg).mc.willbeTrapped = false;
if(eval("a" + this.trg).mc.health <= 0)
{
eval("a" + this.trg).mc.trapped = true;
}
else
{
eval("a" + this.trg).mc.trapDelay = _root.trapDelay[this.level - 1];
}
}
this.swapDepths(99999);
removeMovieClip(this);
this.swapDepths(99995);
removeMovieClip(this);
}
}
function towerMove()
{
var snd = new Sound(this);
this.swap();
if(activeTower != this.num)
{
this.sensor._visible = false;
this.tower.transform.colorTransform = unSelectedTower;
}
this.i = 1;
while(this.i < creatureNum)
{
if(this.sensor.hitTest(eval("_global.a" + this.i).mc._x,eval("_global.a" + this.i).mc._y,true) && this.busy != true && eval("_global.a" + this.i).mc.health > eval("_global.a" + this.i).mc.estimatedDamage && (eval("_global.a" + this.i).mc.estimatedDamage == 0 || eval("_global.a" + this.i).mc.health > missileDamage[this.towerType][this.level - 1] + eval("_global.a" + this.i).mc.estimatedDamage) && (this.towerType != 5 || eval("_global.a" + this.i).mc.willbeTrapped != true) && (this.towerType != 4 || creatureType == 4) && (creatureType != 4 || this.towerType != 2 && this.towerType != 3))
{
this.busy = true;
missilesNum++;
if(this.towerType != 3)
{
if(creatureType == 2 && (this.towerType == 1 || this.towerType == 6))
{
eval("_global.a" + this.i).mc.estimatedDamage += missileDamage[this.towerType][this.level - 1] / 2;
}
else
{
eval("_global.a" + this.i).mc.estimatedDamage += missileDamage[this.towerType][this.level - 1];
}
_root.attachMovie("missile" + this.towerType,"missile" + missilesNum,_root.getNextHighestDepth(),{_x:this._x,_y:this._y - 20});
eval("missile" + missilesNum).onEnterFrame = missileMove;
eval("missile" + missilesNum).trg = this.i;
eval("missile" + missilesNum).toTarget = missileSpeed[this.towerType - 1];
if(this.towerType == 1 || this.towerType == 6)
{
eval("missile" + missilesNum)._rotation = Math.atan((this._y - eval("a" + this.i).mc._y) / (this._x - eval("a" + this.i).mc._x)) * 180 / 3.141592653589793 + 90;
}
eval("missile" + missilesNum).towerType = this.towerType;
eval("missile" + missilesNum).level = this.level;
if(this.towerType == 4)
{
this.tower.gotoAndPlay(2);
snd.attachSound("_zvezdochka");
snd.start();
}
else if(this.towerType == 5)
{
snd.attachSound("_setka");
snd.start();
}
if(this.towerType == 5)
{
eval("_global.a" + this.i).mc.willbeTrapped = true;
}
}
else
{
this.field._width = this.field._height = this.sensor._width / 2;
this.field.gotoAndPlay(2);
this.i = 1;
while(this.i < _root.creatureNum)
{
if(this.sensor.hitTest(eval("_global.a" + this.i).mc._x,eval("_global.a" + this.i).mc._y,true) && (eval("_global.a" + this.i).mc.estimatedDamage == 0 || eval("_global.a" + this.i).mc.health > missileDamage[this.towerType][this.level - 1] + eval("_global.a" + this.i).mc.estimatedDamage))
{
if(creatureType == 1)
{
eval("_global.a" + this.i).mc.health -= missileDamage[this.towerType][this.level - 1] / 2;
}
else
{
eval("_global.a" + this.i).mc.health -= missileDamage[this.towerType][this.level - 1];
}
}
this.i = this.i + 1;
}
}
this.i = creatureNum;
this.counter = 0;
}
this.i = this.i + 1;
}
if(this.busy == true)
{
if(this.counter < towerDelay[this.towerType][this.level - 1])
{
this.counter = this.counter + 1;
}
else
{
this.busy = false;
}
}
}
function cursorMove()
{
this._x = Math.round((_xmouse - cellSize) / 10) * 10;
this._y = Math.round((_ymouse - cellSize) / 10) * 10;
}
function creatureMove()
{
if(this.health <= 0)
{
if(this.trapped != true)
{
var snd = new Sound(this);
snd.attachSound("_creature" + creatureType + "Death" + (random(3) + 1));
snd.start();
}
if(this.trapped == true)
{
if(this.umer != true)
{
this.umer = true;
this.cr.gotoAndStop("catched");
gold += creatureCost[creatureGroupNum - 1] * 2;
this.t = getTimer();
}
if(getTimer() - this.t > 900)
{
this.swapDepths(99999);
removeMovieClip(this);
totalCatched++;
}
}
else
{
_root.razriv(this._x,this._y - 15,25);
this.swapDepths(99999);
removeMovieClip(this);
totalKilled++;
gold += creatureCost[creatureGroupNum - 1];
}
_root.allDead = true;
next._alpha = 100;
p._alpha = 100;
i = 1;
while(i < creatureNum)
{
if(eval("_global.a" + i).mc._x != undefined)
{
i = _root.creatureNum;
_root.allDead = false;
next._alpha = 20;
p._alpha = 20;
}
i++;
}
}
this.healthBar._xscale = this.health * 100 / this.fullHealth;
i = 0;
while(i < creatureNum)
{
if(this.newDir == 4 && eval("_global.a" + i).mc.newDir != 8 || this.newDir == 8 && eval("_global.a" + i).mc.newDir != 4)
{
if(this._y > eval("_global.a" + i + ".mc")._y && this.getDepth() < eval("_global.a" + i + ".mc").getDepth())
{
this.swapDepths("_global.a" + i + ".mc");
}
if(this._y < eval("_global.a" + i + ".mc")._y && this.getDepth() > eval("_global.a" + i + ".mc").getDepth())
{
this.swapDepths("_global.a" + i + ".mc");
}
}
i++;
}
}
function creatureGen(num)
{
zast = false;
currentCreepWave++;
tossTowers();
_root.creatureNum = 0;
_root.allDead = false;
_root.next._alpha = 20;
_root.p._alpha = 20;
var snd = new Sound(this);
snd.attachSound("_cr" + creatureType + "appear1");
snd.start();
if(creatureType >= 5)
{
creatureType = 1;
creatureGroupNum++;
}
if(num == undefined)
{
num = 1;
}
_root.creatureNum = 1;
while(_root.creatureNum <= num)
{
set("_global.a" + _root.creatureNum,new Agent({x:3,y:-1 - _root.creatureNum * spaceBetweenCreatures,map:map}));
eval("_global.a" + _root.creatureNum).num = _root.creatureNum;
eval("_global.a" + _root.creatureNum).mc.num = _root.creatureNum;
eval("_global.a" + _root.creatureNum).mc.trapDelay = 0;
eval("_global.a" + _root.creatureNum).mc.cacheAsBitmap = true;
eval("_global.a" + _root.creatureNum).mc.gotoAndStop(creatureType);
eval("_global.a" + _root.creatureNum).mc.estimatedDamage = 0;
eval("_global.a" + _root.creatureNum).mc.health = groupHealth[creatureGroupNum - 1];
eval("_global.a" + _root.creatureNum).mc.fullHealth = groupHealth[creatureGroupNum - 1];
_root.creatureNum = _root.creatureNum + 1;
}
_root.pathFinder();
}
function tossTowers()
{
i = 0;
while(i <= towersNum)
{
eval("tower" + i).swapDepths(10000 + eval("tower" + i)._y * 10 + eval("tower" + i)._x / 10);
i++;
}
}
function placeSquare(xx, yy, color)
{
obstCounter++;
if(color == undefined)
{
color = 5734680;
}
this.createEmptyMovieClip("square_mc" + obstCounter,this.getNextHighestDepth());
eval("square_mc" + obstCounter)._x = xx;
eval("square_mc" + obstCounter)._y = yy;
eval("square_mc" + obstCounter).beginFill(color);
eval("square_mc" + obstCounter).moveTo(0,0);
eval("square_mc" + obstCounter).lineTo(squareSize,0);
eval("square_mc" + obstCounter).lineTo(squareSize,squareSize);
eval("square_mc" + obstCounter).lineTo(0,squareSize);
eval("square_mc" + obstCounter).lineTo(0,0);
eval("square_mc" + obstCounter).endFill();
}
function buttonsRollOut()
{
_root.msg1 = undefined;
_root.msg2 = undefined;
}
function clearAll()
{
globalSound.stop();
target.swapDepths(99999);
removeMovieClip(target);
towerTable.swapDepths(99999);
towerTable.removeMovieClip();
cursor.swapDepths(99999);
cursor.removeMovieClip();
i = 0;
while(i <= creatureNum)
{
eval("a" + i).mc.swapDepths(99999);
eval("a" + i).mc.removeMovieClip();
delete ("a" + i);
i++;
}
i = 0;
while(i <= towersNum)
{
eval("tower" + i).swapDepths(99999);
eval("tower" + i).removeMovieClip();
i++;
}
}
function availableorNot()
{
i = 1;
while(i < 8)
{
if(gold < towerCost[i][0])
{
eval("twr" + i).transform.colorTransform = unavailable;
}
else
{
eval("twr" + i).transform.colorTransform = unSelectedTower;
}
i++;
}
}
function pathFinder()
{
var mx = 30;
var my = 41;
if(map[my][mx] == 1 || map[my][mx] == undefined)
{
trace("tile not allowed");
return false;
}
var target = this.attachMovie("target","target",1,{_x:mx * 10,_y:my * 10});
a1.onArrive = function()
{
target.swapDepths(99999);
target.removeMovieClip();
};
i = 1;
while(i < _root.creatureNum)
{
eval("a" + i).walkTo(mx,my);
eval("a" + i).onArrive = function()
{
eval("a" + i).mc.swapDepths(99999);
eval("a" + i).mc.removeMovieClip();
rp--;
_root.allDead = true;
next._alpha = 100;
i = 1;
while(i < creatureNum)
{
if(eval("_global.a" + i).mc._x != undefined)
{
i = _root.creatureNum;
_root.allDead = false;
next._alpha = 20;
}
i++;
}
};
i++;
}
}
_global.Agent = function(initObj)
{
for(var _loc3_ in initObj)
{
this[_loc3_] = initObj[_loc3_];
}
this.attachMe();
};
o = Agent.prototype;
o.attachMe = function()
{
if(_root.currentCreepWave > 12)
{
if(_root.currentCreepWave % 12 == 8)
{
_root.ag = "agent2";
}
else if(_root.currentCreepWave % 12 == 0)
{
_root.ag = "agent3";
}
else if(_root.currentCreepWave % 12 == 4)
{
_root.ag = "agent";
}
}
this.mc = _root.attachMovie(_root.ag,"cr" + _root.creatureNum,900 + _root.creatureNum,{_x:this.x * 10 + 10,_y:this.y * 10 + 10});
this.mc.onEnterFrame = creatureMove;
};
o.walkTo = function(tx, ty)
{
this.tx = tx;
this.ty = ty;
if(this.loop !== this.walking)
{
this.dir = 0;
this.dir = this.getApproximatedDirection();
}
this.visitedNodes = [];
this.loop = this.walking;
};
o.getApproximatedDirection = function()
{
var _loc5_ = this.map;
var _loc4_ = this.x;
var _loc3_ = this.y;
var _loc23_ = this.dir;
var _loc22_ = this.tx;
var _loc20_ = this.ty;
var _loc9_ = _loc22_ - _loc4_;
var _loc8_ = _loc20_ - _loc3_;
var _loc10_ = Math.abs;
var _loc13_ = _loc10_(_loc9_);
var _loc12_ = _loc10_(_loc8_);
var _loc16_ = _loc13_ >= _loc12_;
var _loc15_ = _loc12_ >= _loc13_;
var _loc2_ = [];
var _loc14_ = _loc5_[_loc3_];
if((~_loc14_[_loc4_ + 1]) & 1 && _loc23_ != 2)
{
var _loc25_ = undefined;
if((_loc25_ = _loc9_ >= 0) && _loc16_)
{
_loc2_.push({dir:1,value:3});
}
else if(_loc25_)
{
_loc2_.push({dir:1,value:2});
}
else if(_loc23_ == 1)
{
_loc2_.push({dir:1,value:1});
}
else
{
_loc2_.push({dir:1,value:0});
}
}
if((~_loc14_[_loc4_ - 1]) & 1 && _loc23_ != 1)
{
var _loc21_ = undefined;
if((_loc21_ = _loc9_ <= 0) && _loc16_)
{
_loc2_.push({dir:2,value:3});
}
else if(_loc21_)
{
_loc2_.push({dir:2,value:2});
}
else if(_loc23_ == 2)
{
_loc2_.push({dir:2,value:1});
}
else
{
_loc2_.push({dir:2,value:0});
}
}
if((~_loc5_[_loc3_ + 1][_loc4_]) & 1 && _loc23_ != 8)
{
var _loc24_ = undefined;
if((_loc24_ = _loc8_ >= 0) && _loc15_)
{
_loc2_.push({dir:4,value:3});
}
else if(_loc24_)
{
_loc2_.push({dir:4,value:2});
}
else if(_loc23_ == 4)
{
_loc2_.push({dir:4,value:1});
}
else
{
_loc2_.push({dir:4,value:0});
}
}
if((~_loc5_[_loc3_ - 1][_loc4_]) & 1 && _loc23_ != 4)
{
var _loc19_ = undefined;
if((_loc19_ = _loc8_ <= 0) && _loc15_)
{
_loc2_.push({dir:8,value:3});
}
else if(_loc19_)
{
_loc2_.push({dir:8,value:2});
}
else if(_loc23_ == 8)
{
_loc2_.push({dir:8,value:1});
}
else
{
_loc2_.push({dir:8,value:0});
}
}
_loc2_.sortOn("value");
var _loc17_ = _loc2_.length;
var _loc11_ = _loc2_[_loc17_ = _loc17_ - 1];
var _loc18_ = _loc2_[_loc17_ = _loc17_ - 1];
if(_loc11_.value == _loc18_.value)
{
var _loc7_ = _loc11_.dir + _loc18_.dir;
if(_loc7_ == 5 && (~_loc5_[_loc3_ + 1][_loc4_ + 1]) & 1)
{
return 5;
}
if(_loc7_ == 6 && (~_loc5_[_loc3_ + 1][_loc4_ - 1]) & 1)
{
return 6;
}
if(_loc7_ == 9 && (~_loc5_[_loc3_ - 1][_loc4_ + 1]) & 1)
{
return 9;
}
if(_loc7_ == 10 && (~_loc5_[_loc3_ - 1][_loc4_ - 1]) & 1)
{
return 10;
}
}
var _loc6_ = _loc2_.pop().dir;
if(_loc6_ == this.visitedNodes[_loc3_][_loc4_])
{
alert += "\rvisited";
_loc6_ = _loc2_.pop().dir;
}
this.mc.newDir = _loc6_;
if(_loc23_ != _loc6_)
{
if(this.visitedNodes[_loc3_] == undefined)
{
this.visitedNodes[_loc3_] = [];
}
this.visitedNodes[_loc3_][_loc4_] = _loc6_;
alert += "\rmarker " + [_loc4_,_loc3_];
}
return _loc6_;
};
o.walking = function()
{
var _loc4_ = this.dir;
var _loc3_ = this.mc;
var _loc5_ = 2;
_loc5_ = _root.speed;
if(creatureType == 3)
{
_loc5_ = 3.3333333333333335;
}
if(this.dirr != this.dir)
{
if(this.dir == 1)
{
this.mc.cr.gotoAndPlay("right");
}
else if(this.dir == 2)
{
this.mc.cr.gotoAndPlay("left");
}
else if(this.dir == 8)
{
this.mc.cr.gotoAndPlay("up");
}
else if(this.dir == 4)
{
this.mc.cr.gotoAndPlay("down");
}
this.dirr = this.dir;
}
if(this.mc.trapped != true)
{
if(this.mc.trapDelay == 0)
{
if(_loc4_ == 1)
{
_loc3_._x += _loc5_;
}
else if(_loc4_ == 2)
{
_loc3_._x -= _loc5_;
}
else if(_loc4_ == 4)
{
_loc3_._y += _loc5_;
}
else if(_loc4_ == 8)
{
_loc3_._y -= _loc5_;
}
else if(_loc4_ == 5)
{
_loc3_._x += _loc5_;
_loc3_._y += _loc5_;
}
else if(_loc4_ == 9)
{
_loc3_._x += _loc5_;
_loc3_._y -= _loc5_;
}
else if(_loc4_ == 10)
{
_loc3_._x -= _loc5_;
_loc3_._y -= _loc5_;
}
else if(_loc4_ == 6)
{
_loc3_._x -= _loc5_;
_loc3_._y += _loc5_;
}
if(_loc3_._x > 0 && _loc3_._y > 0)
{
if(_loc3_._x % 10 < 1 || _loc3_._x % 10 > 9)
{
_loc3_._x = Math.round(_loc3_._x);
}
if(_loc3_._y % 10 < 1 || _loc3_._y % 10 > 9)
{
_loc3_._y = Math.round(_loc3_._y);
}
}
if(_loc3_._y < 0)
{
if(_loc3_._y % 10 > -1 || _loc3_._y % 10 < -9)
{
_loc3_._y = Math.round(_loc3_._y);
}
}
if(_loc3_._x % 10 == 0 && _loc3_._y % 10 == 0)
{
if(_loc4_ == 1)
{
this.x += 1;
}
else if(_loc4_ == 2)
{
this.x -= 1;
}
else if(_loc4_ == 4)
{
this.y += 1;
}
else if(_loc4_ == 8)
{
this.y -= 1;
}
else if(_loc4_ == 5)
{
this.x += 1;
this.y += 1;
}
else if(_loc4_ == 9)
{
this.x += 1;
this.y -= 1;
}
else if(_loc4_ == 10)
{
this.x -= 1;
this.y -= 1;
}
else if(_loc4_ == 6)
{
this.x -= 1;
this.y += 1;
}
if(this.x == this.tx && this.y == this.ty)
{
delete this.loop;
this.onArrive();
return undefined;
}
this.dir = this.getApproximatedDirection();
}
}
else
{
this.mc.trapDelay--;
}
}
};
var map = Array();
map[0] = [0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1];
map[1] = [0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1];
map[2] = [0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1];
map[3] = [0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1];
map[4] = [0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1];
map[5] = [0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1];
map[6] = [0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1];
map[7] = [0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1];
map[8] = [0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1];
map[9] = [0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,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35] = [0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1];
map[36] = [0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1];
map[37] = [0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,1];
map[38] = [0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,1];
map[39] = [0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,1];
map[40] = [0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,1];
map[41] = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,1];
map[42] = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,1];
map[43] = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,1];
map[44] = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,3,3,3,3,3,3,3,3,3,3];
map[45] = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3];
ag = "agent";
obstCounter = 0;
cellSize = 10;
squareSize = 8;
speed = 2;
kaplyaCounter = 0;
spaceBetweenCreatures = 2;
towersNum = 0;
missilesNum = 0;
animationsNum = 6;
creatureGroupNum = 1;
gold = 600;
rp = 20;
tower5cost = 50;
towerType = 0;
next._alpha = 20;
allDead = false;
p.p._visible = false;
creatureType = 0;
delay = undefined;
currentCreepWave = 0;
totalKilled = 0;
totalCatched = 0;
pausee = false;
zast = false;
selectedTower = new flash.geom.ColorTransform();
selectedTower.alphaMultiplier = 0.8;
selectedTower.redMultiplier = 15;
selectedTower.greenMultiplier = 0.4;
selectedTower.blueMultiplier = 0.4;
unSelectedTower = new flash.geom.ColorTransform();
unSelectedTower.alphaMultiplier = 1;
unSelectedTower.redMultiplier = 1;
unSelectedTower.greenMultiplier = 1;
unSelectedTower.blueMultiplier = 1;
unavailable = new flash.geom.ColorTransform();
unavailable.alphaMultiplier = 1;
unavailable.redMultiplier = 0.4;
unavailable.greenMultiplier = 0.4;
unavailable.blueMultiplier = 0.4;
var trapDelay = Array();
trapDelay = [30,40,50,60,70];
var groupHealth = Array();
i = 0;
var creatureCost = Array();
xx = 2;
while(xx < 100)
{
groupHealth[i] = Math.round(xx * xx + i * i / 1.3) * 10;
creatureCost[i] = 10 + i;
if(groupHealth[i] > 3000)
{
groupHealth[i] += i * i * 8;
}
i++;
xx++;
}
var towerCost = Array();
towerCost[1] = [50,100,150,200,300];
towerCost[2] = [100,100,300,700,1200];
towerCost[3] = [500,400,600,900,2000];
towerCost[4] = [600,400,600,1000,1000];
towerCost[5] = [1000,600,700,900,1200];
towerCost[6] = [2000,1000,2000,2000,2000];
var missileDamage = Array();
missileDamage[1] = [10,20,50,100,150];
missileDamage[2] = [40,80,220,500,900];
missileDamage[3] = [80,180,360,640,1100];
missileDamage[4] = [100,230,460,820,1200];
missileDamage[5] = [100,160,250,400,700];
missileDamage[6] = [100,200,400,600,800];
var towerDistance = Array();
towerDistance[1] = [220,230,240,250,260];
towerDistance[2] = [230,240,260,280,300];
towerDistance[3] = [100,110,120,130,150];
towerDistance[4] = [270,280,290,330,350];
towerDistance[5] = [200,220,240,260,280];
towerDistance[6] = [300,310,320,330,340];
var towerDelay = Array();
towerDelay[1] = [24,23,22,21,20];
towerDelay[2] = [30,28,26,23,20];
towerDelay[3] = [25,24,22,21,20];
towerDelay[4] = [20,18,15,12,10];
towerDelay[5] = [50,50,45,40,35];
towerDelay[6] = [4,4,4,4,4];
var missileSpeed = Array();
missileSpeed = [9,15,0,35,20,12];
globalSound.stop();
globalSound = new Sound(this);
globalSound.attachSound("_music");
globalSound.start(0,1000);
globalSound.setVolume(100);
_root.attachMovie("instr","instr",_root.getNextHighestDepth(),{_x:10,_y:9});
_root.pausee = true;
_root.onMouseDown = function()
{
if(_root.pausee != true)
{
click = true;
i = 0;
while(i < towersNum + 1)
{
if(cursor.sensor.hitTest(eval("tower" + i)._x,eval("tower" + i)._y))
{
towerTable.swapDepths(99999);
towerTable.removeMovieClip();
snsr.swapDepths(99999);
removeMovieClip(snsr);
_root.attachMovie("snsr","snsr",_root.getNextHighestDepth(),{_x:eval("tower" + i)._x,_y:eval("tower" + i)._y});
snsr._width = eval("tower" + i)._width;
snsr._height = eval("tower" + i)._height;
activeTower = i;
towerType = 0;
cursor._visible = false;
_root.attachMovie("towerTable","towerTable",_root.getNextHighestDepth(),{_x:390,_y:155});
eval("tower" + i).tower.transform.colorTransform = selectedTower;
i = towersNum;
click = false;
}
i++;
}
if(map[cursor._y / 10][cursor._x / 10] == 1 && map[cursor._y / 10 - 1][cursor._x / 10] == 1 && map[cursor._y / 10][cursor._x / 10 - 1] == 1 && map[cursor._y / 10 - 1][cursor._x / 10 - 1] == 1 && gold >= towerCost[towerType][0] && towerType != 0 && click == true)
{
towersNum++;
gold -= towerCost[towerType][0];
_root.attachMovie("tower" + towerType,"tower" + towersNum,10000 + cursor._y * 10 + cursor._x / 10,{_x:_root.cursor._x + 9,_y:_root.cursor._y + 12});
if(towerType == 5)
{
towerCost[5][0] += 250;
}
map[Math.round(cursor._y / 10)][Math.round(cursor._x / 10)] = map[Math.round(cursor._y / 10) - 1][Math.round(cursor._x / 10)] = map[Math.round(cursor._y / 10)][Math.round(cursor._x / 10) - 1] = map[Math.round(cursor._y / 10) - 1][Math.round(cursor._x / 10) - 1] = 3;
eval("tower" + towersNum).num = towersNum;
eval("tower" + towersNum).towerType = towerType;
eval("tower" + towersNum).onEnterFrame = towerMove;
eval("tower" + towersNum).level = 1;
eval("tower" + towersNum).sensor._height = eval("tower" + towersNum).sensor._width = towerDistance[towerType][0];
activeTower = 0;
snsr.swapDepths(99999);
removeMovieClip(snsr);
towerTable.swapDepths(99999);
towerTable.removeMovieClip();
click = false;
}
if(towerTable.hitTest(_xmouse,_ymouse,false))
{
click = false;
}
if(click == true)
{
snsr.swapDepths(99999);
removeMovieClip(snsr);
activeTower = 0;
towerType = 0;
click = false;
towerTable.swapDepths(99999);
towerTable.removeMovieClip();
cursor._visible = false;
}
}
};
MovieClip.prototype.swap = function()
{
i = 1;
while(i < creatureNum)
{
if(this._y > eval("a" + i).mc._y && this.getDepth() < eval("a" + i).mc.getDepth())
{
this.swapDepths(eval("a" + i).mc);
}
if(this._y < eval("a" + i).mc._y && this.getDepth() > eval("a" + i).mc.getDepth())
{
this.swapDepths(eval("a" + i).mc);
}
i++;
}
};
i = 1;
while(i < 5)
{
eval("twr" + i).onRollOut = buttonsRollOut;
i++;
}
msg1 = "Instructions";
msg2 = "Choose towers using buttons and place them on the map. Then press START";
_root.attachMovie("cursor","cursor",_root.getNextHighestDepth());
cursor.onEnterFrame = cursorMove;
cursor._visible = false;
tower0.onEnterFrame = towerMove;
mainSound = new Sound(this);
mainSound.setVolume(100);
onEnterFrame = function()
{
if((currentCreepWave == 4 || currentCreepWave == 10 || currentCreepWave == 17 || currentCreepWave == 25 || currentCreepWave == 33 || currentCreepWave == 45) && allDead == true && zast == false && rp > 0)
{
zast = true;
pausee = true;
animationsNum--;
attachMovie("animationsss","anim",_root.getNextHighestDepth());
}
currentGroupHealth = groupHealth[creatureGroupNum - 1];
costPerUnit = creatureCost[creatureGroupNum - 1];
i = 1;
while(i < _root.creatureNum)
{
eval("a" + i).loop();
i++;
}
availableorNot();
if(rp <= 0)
{
rp = 20;
snsr.swapDepths(99999);
snsr.removeMovieClip();
gotoAndStop("gameOver");
play();
}
};
stop();